<?php session_start();
	include('../controller/functions.php');
	User::connection();

$userArr	= array('admin','teacher','student');
	if(!in_array($_SESSION['user'],$userArr)) {
	User::validSession();

}
$user_id 	= $_SESSION['curuser'];	
if ($_GET['q'] == 'logout') 
{
	User::user_logout();
		print '		
			<script type="text/javascript">		
			window.location = "../login_r.php";
			</script>
			';

}


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="../images/fav.ico">
<link rel="icon" type="image/gif" href="../images/fav.ico">
<title>Sent Messages</title>

	<link rel="stylesheet" href="../css/style2.css" type="text/css" charset="utf-8" />
    <link rel="stylesheet" href="../css/front.css" type="text/css" charset="utf-8" />
     <link rel="stylesheet" href="../css/general.css" type="text/css" charset="utf-8" />
    	<link type="text/css" href="../css/demo.css" rel="stylesheet" />
      
</head>
<body>

 <div id="page">
<div id="wrapper">
        
        		   <div class="header_top" id="header_top"> </div>
  </div>
  <div class="header2"></div> 
	<div class="header"><!--open logo -->
		  </div><!--end header -->
	<!-- close logo-->
<!-- hide the client inquiries php-->
    <?php
    echo '<div id="nav">';
    echo '<div class="underlinemenu">';
	include('menu_view.php');
	echo '</div>';
    echo '</div>';
	?>
    <div id="header_in"> <!--open header -->
   <p> </p>
    
    <table width="100%" height="56">
     <tr>
       <td width="317" align="left" class="date"> 
        <? User::oras(); ?>
        </td>
            
       <td width="388" align="right"><? User::showPic(); ?></td>
       <td width="279">&nbsp;&nbsp;<? User::showUser(); ?>        </td>
       </tr>
   </table>
     
  
    </div>
    <div id="ex">
    </div>
    
      <p> </p>
       <div id="body"> <!--open body -->
    
	 <div id="sidebar"> 
        <!--<div id="chef_ind"> open chef --><!--close welcome-->

<? echo '<p class="more">';
echo '';
 
   require('sideBar.php');
    
echo'</p>';
?>

         </div>
        
      <!--</div>close left -->
      
      <div id="content"> 
      <div class="desriptionHeader"> <!--open right-->
      <div id="container">
    
         <div class="post3_students"><h1>Message Sent List</h1> </div>
      
            <div class="desriptionHeader"> <!--open right-->
       <div class="postbg1"><!--open booking -->
       
	<table width="680" align="center" bordercolor="#000000" " bgcolor="#ebf9b4" >
	
	<tr>
		<td align="left" colspan="6" class="cat">Messages Sent</td>
    </tr>
        <tr>
            <td class="label" align="center"><strong>Subject</strong></td>
            <td class="label" align="center"><strong>To</strong></td>
            <td class="label" align="center"><strong>Date and Time</strong></td>
            <td class="label" align="center"><strong>Delete</strong></td>
        </tr>

<?
		        
			$queryMsg	 		= " SELECT 						";
			$queryMsg	   	   .= " 	m.date, m.subject, 	";
			$queryMsg	       .= "		u.fname, u.lname,u.user_type, u.userid, m.senderID, ";
			$queryMsg		   .= "		m.messageID				";
			$queryMsg	  	   .= " FROM 						";
			$queryMsg          .= " 	tblmessage m,			";
			$queryMsg          .= " 	tbluser u				";						
			$queryMsg	       .= " WHERE 						";
			$queryMsg	       .= "	m.toID = u.userid		";
			$queryMsg 	       .= " AND	m.senderID = ' $_SESSION[curuser]'	";
						
					$querySmsg = mysql_query($queryMsg);
					$ctr	= 1;
		while($rowMSg = mysql_fetch_assoc($querySmsg))
		{
			$us = $rowMSg['senderID'];
			date_default_timezone_set('Asia/Manila');
			$date = date('l jS \of F Y h:i:s A', strtotime($rowMSg['date']));
			$msgID		 = $rowMSg['messageID'];
			$subject 	 = $rowMSg['subject'];
				
		$a++;
		if ($a%2==1)
		{ 
		echo "<tr bgcolor='#e6e4b1'>";
		}
		else
		{
			echo "<tr bgcolor='#b8cd65'>";	
		}
				print '
					
						<td align="left">'.$ctr.' . <a class="title" href="messageSent.php?messageID='.$msgID.'">'.$subject.'</a></td>
						<td align="center">['.$rowMSg['user_type'].'] - '.$rowMSg['fname']." ".$rowMSg['lname'].'</a></td>
						<td align="center" class="extra">'.$date.'</td>
						
					
						';	
					if($_SESSION['user'] == 'admin' OR $_SESSION['curuser'] == $us)
			
			{
				
				print '
				<td align="center">
				<a href="messageDelete.php?messageID='.$msgID.'" class="otherlink"> <img width="15" height="15" border="0" src="../images/unchecked.gif"> </a>
				
				</td>
				
				';
				
				print("</tr>");
				
			}
			$ctr++;
		
		}
		
		?>
</table>


</div><!--close desc -->
   
        
         </div> <!--close container-->
   			
	  </div><!--close booking -->
   </div><!--close desc -->
    	</div> <!--close right-->
      <div class="clear">&nbsp;</div>
 <!-- footer-->
 <?php 
	  echo '<div id="footer">';
     include('footer_view.php');
      echo '</div>';	
	  ?>

    </div><!-- close body-->
</div><!-- close page-->

</body>
</html>
